package configuration;

import java.util.List;

import org.jgap.FitnessFunction;
import org.jgap.GeneticOperator;
import org.jgap.IChromosome;
import org.jgap.Population;

public class ProfileMutation implements GeneticOperator {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4594796676148704294L;

	@Override
	public void operate(Population pop, List evolved) {
		int popSize = pop.size();
			for(int i=0; i<popSize; i++){
				IChromosome individual = pop.getChromosome(i);
				IChromosome evo = (IChromosome) individual.clone();

				Double r = (new Double(Math.random()))*1000;
				Integer allele = new Integer(r.intValue()%5);

				for(int j=0; j<4; j++){
					Integer alleleValue = (Integer) evo.getGene(allele).getAllele();
					evo.getGene(allele).setAllele(alleleValue+1);
					r = (new Double(Math.random()))*1000;
					allele = new Integer(r.intValue()%5);
				}

				evolved.add( evo );
			}
	}

}
